package com.tiger.web.controller.project;

import com.tiger.common.annotation.Log;
import com.tiger.common.core.controller.BaseController;
import com.tiger.common.core.domain.AjaxResult;
import com.tiger.common.core.domain.model.LoginUser;
import com.tiger.common.core.page.TableDataInfo;
import com.tiger.common.enums.BusinessType;
import com.tiger.common.utils.ServletUtils;
import com.tiger.common.utils.spring.SpringUtils;
import com.tiger.framework.web.service.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tiger.project.domain.ReportInfo;
import com.tiger.project.service.IReportInfoService;


/**
 * 报告信息Controller
 *
 * @author iot
 * @date 2022-12-15
 */
@Api(tags = "报告信息")
@RestController
@RequestMapping("/project/reportInfo")
public class ReportInfoController extends BaseController {
    @Autowired
    private IReportInfoService reportInfoService;

    /**
     * 查询报告信息列表
     */
    @ApiOperation(value = "查询报告信息列表")
    //@PreAuthorize("@ss.hasPermi('project:reportInfo:list')")
    @GetMapping("/list")
        public TableDataInfo list(ReportInfo reportInfo) {
        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
        reportInfo.setCompanyId(loginUser.getDeptId());
        startPage();
        List<ReportInfo> list = reportInfoService.selectReportInfoList(reportInfo);
        return getDataTable(list);
    }


    /**
     * 获取报告信息详细信息
     */
    @ApiOperation(value = "获取报告信息列详细信息")
    //@PreAuthorize("@ss.hasPermi('project:reportInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(reportInfoService.selectReportInfoById(id));
    }

    /**
     * 新增报告信息
     */
    @ApiOperation(value = "新增报告信息")
    //@PreAuthorize("@ss.hasPermi('project:reportInfo:add')")
//    @Log(title = "报告信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ReportInfo reportInfo) {
        return toAjax(reportInfoService.insertReportInfo(reportInfo));
    }

    /**
     * 修改报告信息
     */
    @ApiOperation(value = "修改报告信息")
    //@PreAuthorize("@ss.hasPermi('project:reportInfo:edit')")
//    @Log(title = "报告信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ReportInfo reportInfo) {
        return toAjax(reportInfoService.updateReportInfo(reportInfo));
    }

    /**
     * 删除报告信息
     */
    @ApiOperation(value = "删除报告信息")
    //@PreAuthorize("@ss.hasPermi('project:reportInfo:remove')")
    @Log(title = "报告信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(reportInfoService.deleteReportInfoByIds(ids));
    }
}
